package business;

import entity.Notification;
import entity.NotificationPK;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Stateless
public class NotificationManager {
    
    @PersistenceContext
    private EntityManager entityManager;
    
    public void create(Notification entity) {
        entityManager.persist(entity);
    }
    
    public void save(Notification notification) {
        entityManager.merge(notification);
    }

    public void delete(Notification entity) {
        entityManager.remove(entityManager.find(Notification.class, entity.getNotificationPK()));
    }

    public boolean exists(NotificationPK primaryKey) {
        return entityManager.find(Notification.class, primaryKey) != null;
    }

    public Notification find(NotificationPK primaryKey) {
        return entityManager.find(Notification.class, primaryKey);
    }
}
